function openZoomVideo()
{
	if($('.img_appoggio_zoom_product').attr('src') == undefined)
	return;
	if($('.img_appoggio_zoom_product').attr('src').indexOf('spacer') != -1)
	return;
	
	zoomOpen=true;
	tmpHeightImageZoom = parseInt($('.img_appoggio_zoom_product').height(),10);
	tmpWidthImageZoom = parseInt($('.img_appoggio_zoom_product').width(),10);
	
	$(".wrapper_zoom_product").css({width: window_width+"px", height: (parseInt($('#section_template').height(),10)+HEIGHT_FOOTER)+"px"}).fadeIn();
	//$(".wrapper_zoom_product").find('img.image_zoom_product').hide().css('visibility','visible').attr('src',$('.img_appoggio_zoom_product').attr('src')).fadeIn();
	
	//$(".wrapper_zoom_product").css({width: window_width+"px", height: window_height+"px"}).fadeIn();
	$(".wrapper_zoom_product").find('.content_cnt_desc_prod_zoom .desc_prod_zoom').html();
	$(".wrapper_zoom_product").find('.content_cnt_desc_prod_zoom .nome_prod_zoom').html();
	$(".loader_zoom_prodotti").fadeOut();
	$(".arrow_zoom").fadeOut();
	$(".bt_close_zoom_product").attr('href','javascript:closeVideoFinish()')
	//$(".bt_close_zoom_product").fadeOut();
	$(".wrap_video_zoom").width("100%").height("100%");
	$(".wrap_video_zoom").css({top:"0px", left: "0px", margin:"0px"});
	playVideo();
	
	//$(".wrapper_zoom_product").find('.content_cnt_desc_prod_zoom').html($('.cnt_col_dx_dati .specifiche').html());
	
	
	
	//trackEventAnalytics('Zoom-product', 'Click', window.location.hash.replace("#",""));
	
	//posizionaZoomProduct(false);
}


/******************FUNZIONE PER VERSIONE CON VIDEO SENZA POPUP****************/
var redirect = "";

function playVideo()
{
	//trackEventAnalytics('TAB_ACCESSORIES','click_accessory_<?=$this->items[0]->codAccessori?>','Tab accessory options <?=$tab->diametro?> mm');
	
	var video = base_url+"images/video/pam/PAM_526.mp4";
	
	if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
	//if(isIPad)
	{
		$('#video_zoom').html('<video id="video_ipad" src="'+video+'" type="video/mp4" width="100%" height="100%" controls="controls" />');
		document.getElementById('video_ipad').play();

		$("#video_ipad").bind("ended", function() {
			window.location.href = redirect;
			//$('.play_video_home').show();
			//$('#video_zoom').css('display','none');
		});
		$("#video_ipad").bind("playing", function() {
			$('.play_video_home').hide();
			$('#video_zoom').css('display','inline');
		});
		/*
		document.getElementById('video_ipad').addEventListener('ended',myHandler,false);
	    function myHandler(e) {
	        if(!e) { e = window.event; }
	        alert('end')
	        // What you want to do after the event
	    }
	    var video = $("#video_ipad").get(0);          
		video.addEventListener('ended', myHandler);
		*/
	}
	else
	{	
	
		var data = new Date();
		var date = data.getHours() + ":" + data.getMinutes() + ":" + data.getSeconds() + ":" + data.getMilliseconds();
		
		if (swfobject.hasFlashPlayerVersion("10.0.0")) 
		{	
			var flashvars = {};
			flashvars.autoPlay = "1";
			flashvars.video = video;
			flashvars.loop = "0";
			flashvars.hideControls = "0";
	
			var params = {};
			params.menu = "false";
			params.quality = "high";
			params.wmode = "transparent";
			params.align = "top";
			params.allowscriptaccess = "sameDomain";
			params.allowfullscreen = "true";
			var attributes = {};
			//attributes.id = "flash_gallery_video_swf_header";
			//attributes.name = "flash_gallery_video_swf_header";	
			swfobject.embedSWF(base_url+"modules/mod_home_page/tmpl/AdactoVideoPlayer.swf?d="+date,'video_zoom', "100%", "100%", "10.0.0", false, flashvars, params, attributes);
			//setScroller();
			//$('#video_manifattura').css('display','inline');
			//$('object#1').css('display','inline');
		}
	}			
	
}
function setRedirect(url)
{
	redirect = url;
}

/******************FUNZIONE PER VERSIONE CON VIDEO SENZA POPUP****************/
function changeStatusVideo()
{
	if(videoInPlay)
	{
		videoInPlay = false;
		window.location.href = redirect;
	}
	else
	{
		videoInPlay = true;
		$('.play_video_home').hide();
		$('.cover').hide();
	}	
	
}




/*
function startVideo()
{	
	var video = base_url+"images/video/panerai_teaser_chrono_090114.mp4";
	
	$('.cover_video.cover_'+indexElement ).fadeOut();
	$('.cnt_desc_cover_video').fadeOut();
	if(navigator.platform.indexOf("iPad") == -1 && navigator.platform.indexOf("iPhone") == -1)
	$('.bt_close_open_video').show();
	$('.separatore_thumb').hide();
	
	$('.wrap_tumb_video').animate({
		bottom: "-"+HEIGHT_THUMB_CONTAINER+'px'
	  }, 300, function(){

		//al completamento dell'animazione sulle thumb apro il video
		var widthContentDesc = parseInt($("#container_video").width(),10);
		var heightContentDesc = parseInt($("#container_video").height(),10);
		
		if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
		{
			$('#video_flash').html('<video id="video_ipad" src="' + video + '" type="video/mp4" width='+widthContentDesc+' height='+heightContentDesc+' controls="controls" />');
			document.getElementById('video_ipad').play();	
		}
		else
		{
			var data = new Date();
			var date = data.getHours() + ":" + data.getMinutes() + ":" + data.getSeconds() + ":" + data.getMilliseconds() + ":";
			if (swfobject.hasFlashPlayerVersion("10.0.0")) 
			{
				var flashvars = {};
				flashvars.autoPlay = "1";
				flashvars.video = video;
				flashvars.loop = "0";
				flashvars.hideControls = "0";
		
				var params = {};
				params.menu = "false";
				params.quality = "high";
				params.wmode = "transparent";
				params.align = "top";
				params.allowscriptaccess = "sameDomain";
				params.allowfullscreen = "true";
				var attributes = {};
				//attributes.id = "flash_gallery_video_swf_header";
				//attributes.name = "flash_gallery_video_swf_header";	
				swfobject.embedSWF(base_url+"/modules/mod_video/AdactoVideoPlayer.swf?d="+date, "video_flash", widthContentDesc, heightContentDesc, "10.0.0", false, flashvars, params, attributes);
			}
		}
		
		$("#container_video").fadeIn();
		
		var tmpTitolo = $('.item_thumb_video[idVideo="'+idv+'"]').attr('titoloVideo');
;
		$('.container_titolo_video_open').html(removeHTMLTags(tmpTitolo));
		
		
		//trackEventAnalytics('Videos', 'Play', removeHTMLTags(tmpTitolo));
		
		$('.cnt_social_zoom_video').animate({
			bottom: "0px"
		}, 300, function(){});
		
	});
}




function playVideoIpad()
{

	document.getElementById('video_ipad').play();
}

function pause()
{
	if(FIRST_LOAD_VIDEO && document.getElementById('video_flash') != null && document.getElementById('video_flash') != "undefined")
	{
		//alert('pause')
		document.getElementById('video_flash').pauseMediaElementToJS();
	}
}


function closeVideo()
{
	if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
	$('.bt_close_open_video_menu').css('visibility','hidden');
	
	if($('.vertical_zoom_product.video').css('display') != 'none')
		$('.vertical_zoom_product.video').hide();
	
	var indexElement = indexElementCoverVideo%2;
	if(navigator.platform.indexOf("iPad") == -1 && navigator.platform.indexOf("iPhone") == -1)
	$('.bt_close_open_video').hide();
	$('.cover_video.cover_'+indexElement ).fadeIn();
	$('.cnt_desc_cover_video').fadeIn();
	$('.separatore_thumb').show();
	
	$('.cnt_social_zoom_video').animate({
		bottom: "-"+HEIGHT_THUMB_CONTAINER+'px'
	  }, 300, function(){
		 $('.wrap_tumb_video').animate({
			bottom: "0px"
		  }, 300, function(){ });
	});
	if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
	$('#video_flash').html('');
	$("#container_video").fadeOut();
	
	pause();
	videoOpen=false;
	FIRST_LOAD_VIDEO = false;
}

*/
function closeVideoFinish()
{
	document.getElementById('video_zoom').pauseMediaElementToJS();
	window.location.href = redirect;
	$(".wrapper_zoom_product").fadeOut();
	//closeVideo();
	//var tmpArr = window.location.hash.replace("#","").split("=");
	//var sectionLoad = tmpArr[tmpArr.length-2].replace("/idv","");
	//jQuery.historyLoad(sectionLoad);
}
